 <?php
 session_start();
 include_once ("Login/databaseconnection.php");
  date_default_timezone_set("Europe/Paris");
  	$t_d=date("Y/m/d");
	$School_Id=$_GET['School_Id'];
   $Competition_Id=$_GET['Competition_Id'];
   $Date=$_GET['Date'];
   $sqlre=mysql_query("SELECT * FROM deleted_competition");
   $current_table="deleted_competition";
	if(mysql_num_rows($sqlre)!=0)
	{
		$School_Id=$_POST['School_Id'];
		$Competition_Id=$_POST['Competition_Id'];
		$No_Of_Students=$_POST['No_Of_Students'];
    $No_Of_Teachers=$_POST['No_Of_Teachers'];
    $Result=$_POST['Result'];
    $Date=$_POST['Date'];
    $Scope=$_POST['Scope'];
   $Winner=$_POST['Winner'];
    $Deleted_date=$_POST['Deleted_date'];
	$Accessed_By=$_POST['Accessed_By'];
		$_SESSION['Accessed_By']=$Accessed_By;
			$sql=mysql_query("INSERT INTO competition(Competition_Id,School_Id,No_Of_Students,No_Of_Teachers,Result,Date,Scope,Winner,Last_Updated_Date) VALUES('$Competition_Id','$School_Id','$No_Of_Students','$No_Of_Teachers','$Result','$Date','$Scope','$Winner','$t_d')");
			if($sql)
			{
				$resultdel=mysql_query("DELETE FROM deleted_competition WHERE Competition_Id='$Competition_Id' AND Date='$Date' AND School_Id='$School_Id'");
				if(!$resultdel)
{
	 $_SESSION['error']="but this record is not removed from the recycle bin!";
}
$_SESSION['error']="Successfully restored!";
			}
		if(!$sql)
{
	 $_SESSION['error']="Sorry,an error occured  please try again!";
}	
}
?>